<include file="Public:header"/>
<div class="container">
	
	<div class="row">
		<!-- <a href=""><button class="btn btn-success">  修改基地信息</button></a> -->
		<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addPoolModal">       添加池塘
		</button>
		<table class="table table-bordered table-striped col-sm-12" >
	     <caption>池塘基本信息:</caption>
		     <thead>
		        <tr>
		           <th>池塘名称</th>
		           <th>所属基地</th>
		           <th>池塘位置</th>
		           <th>经纬度列表</th>
		           <th>水面面积</th>
		           <th>池塘水深</th>
		           <th>养殖设施设备</th>
                   <th>养殖模式</th>
		           <th>创建时间</th>
		           <th>操作</th>
		        </tr>
		     </thead>
		     <tbody>
		     	<volist name="pool_data" id="vo">
			        <tr>
			           <td>{$vo.pool_name}</td>
			           <td>{$vo.pool_base_id}</td>
			           <td>{$vo.pool_addr}</td>
			           <td>{$vo.pool_coordinate}</td>
			           <td>{$vo.pool_area}</td>
			           <td>{$vo.pool_depth}</td>
			           <td>{$vo.pool_equipment}</td>
			           <td>{$vo.pool_model}</td>
                       <td>{$vo.pool_time}</td>
			           <td><button class="btn btn-danger" data-toggle="modal" data-target="#modifyPoolModal" id="modifyButton" value="{$vo.pool_id}" onclick="change(this)">修改</button></td>
			        </tr>
		        </volist>
		     </tbody>
 		 </table>
	</div>
	
</div>
<!-- modifyPool模态框（Modal） -->
<div class="modal fade" id="modifyPoolModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
		   <div class="modal-dialog">
		      <div class="modal-content">
		         <div class="modal-header">
		            <button type="button" class="close" 
		               data-dismiss="modal" aria-hidden="true">
		                  &times;
		            </button>
		            <h4 class="modal-title" id="myModalLabel">
		               信息修改
		            </h4>
		         </div>
		         <div class="modal-body">
		            <form action="{:U('Home/Safe/modifyPool')}" id="modify_form"role="form" method="post">
		                <div class="form-group">
		            		<label for="">池塘名称</label>
		            		<input type="text" class="form-control" value="" name="pool_name" id="pool_name">
		            	</div>
		            	<div class="form-group">
		            		<label for="">池塘位置</label>
		            		<input type="text" class="form-control" value="" name="pool_addr" id="pool_addr">
		            	</div>
		            	<div class="form-group">
		            		<label for="">经纬度列表</label>
		            		<input type="text" class="form-control" value="" name="pool_coordinate" id="pool_coordinate">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水面面积</label>
		            		<input type="text" class="form-control" value="" name="pool_area" id="pool_area" placeholder="水面面积，例如200平方米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水深</label>
		            		<input type="text" class="form-control" value="" name="pool_depth" id="pool_depth" placeholder="水深，例如100米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖设施设备</label>
		            		<input type="text" class="form-control" value="" name="pool_equipment" id="pool_equipment" placeholder="养殖设施设备">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖模式</label>
		            		<select class="form-control"name="pool_model" id="pool_model">
		            			<option value="0">请选择养殖模式</option>
		            			<option value="大塘混养">大塘混养</option>
		            			<option value="网箱">网箱</option>
		            		</select>
		            	</div>
		            	<label class="control-label" for="input01" name="time">当前时间: {$time} </label>
		            	<div class="form-group" hidden>
		            		<input type="text" class="form-control" value="" name="pool_id" id="pool_id" >
		            	</div>

		            </form>
		         </div>
		         <div class="modal-footer">
		            <button type="button" class="btn btn-default" 
		               data-dismiss="modal">关闭
		            </button>
		            <button type="button"  id="modifyBtn" class="btn btn-primary">
		               提交更改
		            </button>
		         </div>
		      </div><!-- /.modal-content -->
		</div><!-- /.modal -->
</div>

<!-- addpool模态框（Modal） -->
<div class="modal fade" id="addPoolModal" tabindex="-1" role="dialog" 
   aria-labelledby="myModalLabel" aria-hidden="true">
		   <div class="modal-dialog">
		      <div class="modal-content">
		         <div class="modal-header">
		            <button type="button" class="close" 
		               data-dismiss="modal" aria-hidden="true">
		                  &times;
		            </button>
		            <h4 class="modal-title" id="myModalLabel">
		               新池塘信息
		               
		            </h4>
		         </div>
		         <div class="modal-body">
		            <form action="{:U('Baseadmin/Safe/addPool')}" id="addPool_form" role="form" method="post">
		            	<div class="form-group">
		            		<label for="">池塘名称</label>
		            		<input type="text" class="form-control" value="" name="pool_name" id="pool_name">
		            	</div>
		            	<div class="form-group">
		            		<label for="">池塘位置</label>
		            		<input type="text" class="form-control" value="" name="pool_addr" id="pool_addr">
		            	</div>
		            	<div class="form-group">
		            		<label for="">经纬度列表</label>
		            		<input type="text" class="form-control" value="" name="pool_coordinate" id="pool_coordinate">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水面面积</label>
		            		<input type="text" class="form-control" value="" name="pool_area" id="pool_area" placeholder="水面面积，例如200平方米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">水深</label>
		            		<input type="text" class="form-control" value="" name="pool_depth" id="pool_depth" placeholder="水深，例如100米">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖设施设备</label>
		            		<input type="text" class="form-control" value="" name="pool_equipment" id="pool_equipment" placeholder="养殖设施设备">
		            	</div>
		            	<div class="form-group">
		            		<label for="">养殖模式</label>
		            		<select class="form-control"name="pool_model" id="pool_model">
		            			<option value="0">请选择养殖模式</option>
		            			<option value="大塘混养">大塘混养</option>
		            			<option value="网箱">网箱</option>
		            		</select>
		            	</div>
		            	<label class="control-label" for="input01" name="time">当前时间: {$time} </label>

		            </form>
		         </div>
		         <div class="modal-footer">
		            <button type="button" class="btn btn-default" 
		               data-dismiss="modal">关闭
		            </button>
		            <button type="button"  id="addPoolBtn" class="btn btn-primary">
		               提交
		            </button>
		         </div>
		      </div><!-- /.modal-content -->
		</div><!-- /.modal -->

</div>

<include file="Public:footer"/>
<script>
    function change(obj) { 
       
		var val = $(obj).attr('value');
        var url = "{:U('Home/Safe/getChoose/name/pool/val/"+val+"')}";
        $.get(url, function(data, status){
        	$('#pool_id').val(data['pool_id']);
            $('#pool_name').val(data['pool_name']);
            $('#pool_base_id').val(data['pool_base_id']);
            $('#pool_addr').val(data['pool_addr']);
            $('#pool_coordinate').val(data['pool_coordinate']);
            $('#pool_area').val(data['pool_area']);
            $('#pool_depth').val(data['pool_depth']);
            $('#pool_equipment').val(data['pool_equipment']);
            $('#pool_model').val(data['pool_model']);
        });

    } 
	$(document).ready(function(){
        $('#addPoolBtn').click(function(){

        	 var action= $('#addPool_form').attr('action');
        	 var Formattr=$('#addPool_form').serialize();
             $.post(action, Formattr,function(data,status) {
                 
                 if(status == "success") {
                    alert( "添加成功！");
                 }else{
                 	alert("添加失败！");
                 }
                 setTimeout("window.location.href=\"{:U('Baseadmin/Safe/index')}\"",500);
             });
        });
      
      
        $('#modifyBtn').click(function(){

        	 var action= $('#modify_form').attr('action');
        	 var Formattr=$('#modify_form').serialize();
	         console.log(Formattr);
             $.post(action, Formattr,function(data,status) {
                 
                 if(status == "success") {
                    alert( "修改成功！");
                 }else{
                 	alert("修改失败！");
                 }
                 setTimeout("window.location.href=\"{:U('Baseadmin/Safe/index')}\"",200);
             });
        });
	});

</script>
      
   

